export default {
  data() {
    return {
      phone: '',
      list: [],
      PageIndex: 1,
      PageSize: 10,
      loadStatus: ['loadmore', 'loading', 'nomore'],
      loadStatusId: 0,
      total: 0
    }
  },
  filters: {
    cutString(str, len) {
		  if (str.length * 2 <= len) {
		    return str
		  }
		  let strlen = 0
		  let s = ''
		  for (let i = 0; i < str.length; i++) {
		    s = s + str.charAt(i)
		    if (str.charCodeAt(i) > 128) {
		      strlen = strlen + 2
		      if (strlen >= len) {
		        return s.substring(0, s.length - 1) + '...'
		      }
		    } else {
		      strlen = strlen + 1
		      if (strlen >= len) {
		        return s.substring(0, s.length - 2) + '...'
		      }
		    }
		  }
		  return s
    },
  },
  methods: {
    select(dealUserInfo) {
      // var pages = getCurrentPages();
      // var prevPage = pages[pages.length - 2]; //上一个页面
      // //直接调用上一个页面的setData()方法，把数据存到上一个页面中去
      // // 上一个页面最后设置userdata
      // prevPage._data.dealUserInfo=dealUserInfo
      // console.log(prevPage._data.dealUserInfo)
		  uni.$emit('selectUser', dealUserInfo)
      uni.navigateBack({
        delta: 1
      })
    },
    gos(item) {
      uni.navigateTo({
        url: '/pages_Sxy/' + item + '/' + item
      })
    },
    // 滑动加载
    reachBottom() {
		  console.log('滑动')
		  // 此tab为空数据
		  // total获取数据总数
		  if (this.total === 0) {
		    this.getUserInfo()
		  } else {
		    let zs = Math.ceil(this.total / 10) //总共多少页
		      if (zs > this.PageIndex) {
		        this.PageIndex++
		        this.getUserInfo()
		      } else {
		        this.loadStatusId = 2
		      }

		  }

    },
    async getUserInfo(){
      uni.showLoading({
        title: '加载中'
      })
      let data={
        'PageIndex': this.PageIndex,
        'PageSize': this.PageSize,
        'Mobile': this.phone
      }
      const res = await this.$api.carOrder.GetAccountListDataList(data)
      try {
        console.log('用户列表', res)
        if (res.code === 200) {
          this.list =[...res.data.list]
          this.total=res.data.total
          let zs = Math.ceil(this.total / 10) //总共多少页
					  if (zs <= this.PageIndex) {
					    this.loadStatusId = 2
					  }
          uni.hideLoading()
        }
      } catch (err) {
        uni.hideLoading()
        console.log(err)
      }

    }
  }
}